import { swap } from '../00.工具/utils.js'

/**
 * 打乱数组的顺序
 * @param {Array} arr 
 * @returns {Array} mixedArray
 */
export const shuffle = arr => {
    const copiedArray = [...arr]
    for (let i = copiedArray.length - 1; i > 0; i--) {
        const randomIndex = Math.floor(Math.random() * (i - 1))
        swap(copiedArray, i, randomIndex)
    }
    return copiedArray
}